

//
//打开新增教育经历
function openaddedu() {
    document.querySelector(".add-edu").style.display="block";
}
//新增教育经历
function addedu() {
    if (document.querySelector(".schoolname").value != "" && document.querySelector(".starttime-edu").value != ""
        && document.querySelector(".endtime-edu").value != "" &&document.querySelector(".education").value != ""
        && document.querySelector(".major").value != "" &&document.querySelector("#major-des").value != ""){

        var addEle="<div class=\"edu-datail\">\n" +
            "                <p>时间：${document.querySelector(\".starttime-edu\").value}到${document.querySelector(\".endtime-edu\").value}</p>\n" +
            "                <p>学校：${document.querySelector(\".schoolname\").value}</p>\n" +
            "                <p>专业：${document.querySelector(\".major\").value}</p>\n" +
            "                <p>学历：${document.querySelector(\".education\").value}</p>\n" +
            "                <p>专业描述：${document.querySelector(\"#major-des\").value}</p> <button class=\"delete-edu\" onclick=\"deleteedu(event)\">删除</button>\n" +
            "                </div>";
        document.querySelector(".main-body-edu").innerHTML+=addEle;
        document.querySelector(".edu-null").style.display="none";
        document.querySelector(".add-edu").style.display="none";

    }else {
        document.querySelector(".error-tip-edu").style.display="block";
    }

}
//关闭新增教育经历
function closeaddedu() {
    document.querySelector(".add-edu").style.display="none";
}
//删除教育经历
function deleteedu(event) {
    event.target.parentElement.style.display="none";
}


//
//打开新增校内荣誉
function openaddhonor() {
    document.querySelector(".add-honor").style.display="block";
}
//新增校内荣誉
function addhonor() {
    if (document.querySelector(".time-honor").value != "" && document.querySelector(".honorname").value != ""){

        var addEle="<div class=\"honor-datail\">\n" +
            "                <p>时间：${document.querySelector(\".time-honor\").value}</p>\n" +
            "                <p>荣誉：${document.querySelector(\".honorname\").value}</p>\n" +
            "                <p>级别：${document.querySelector(\".honorlevel\").value}</p>\n" +
            "                <button class=\"delete-honor\" onclick=\"deletehonor(event)\">删除</button>\n" +
            "                </div>";
        document.querySelector(".main-body-honor").innerHTML+=addEle;
        document.querySelector(".honor-null").style.display="none";
        document.querySelector(".add-honor").style.display="none";

    }else {
        document.querySelector(".error-tip-honor").style.display="block";
    }

}
//关闭新增校内荣誉
function closeaddhonor() {
    document.querySelector(".add-honor").style.display="none";
}
//删除校内荣誉
function deletehonor(event) {
    event.target.parentElement.style.display="none";
}



//
//打开新增技能
function openaddskills() {
    document.querySelector(".add-skills").style.display="block";
}
//新增技能
function addskills() {
    if (document.querySelector(".skillsname").value != "" && document.querySelector(".skillslevel").value != ""){

        var addEle="<div class=\"skills-datail\">\n" +
            "                <p>技能：${document.querySelector(\".skillsname\").value}</p>\n" +
            "                <p>程度：${document.querySelector(\".skillslevel\").value}</p>\n" +
            "                <button class=\"delete-skills\" onclick=\"deleteskills(event)\">删除</button>\n" +
            "                </div>";
        document.querySelector(".main-body-skills").innerHTML+=addEle;
        document.querySelector(".skills-null").style.display="none";
        document.querySelector(".add-skills").style.display="none";

    }else {
        document.querySelector(".error-tip-skills").style.display="block";
    }

}
//关闭新增技能
function closeaddskills() {
    document.querySelector(".add-skills").style.display="none";
}
//删除技能
function deleteskills(event) {
    event.target.parentElement.style.display="none";
}


//导航栏跳转高度
function jumpPage(event){
    var eleText=event.target.innerText;
    if (eleText=="") {
        eleText=event.target.parentElement.innerText;
    }

    var targetList=$(".main-body>div");
    for (var i=0;i<targetList.length;i++){
        var targetText=targetList[i].firstElementChild.nextElementSibling.innerText;
        if (eleText==targetText){
            $("resumeCenter,body").animate({scrollTop:$(targetList[i]).offset().top},{duration:500,easing:"swing"});
        }else if (eleText=="基本信息"){
            $(document).scrollTop(0);
            // $("resumeCenter,body").animate({scrollTop:0},{duration:400,easing:"swing"});
        }
    }

}
$(window).scroll(function () {
    var elelist =$(".left-nav-body>div");
    var targetList=$(".main-body>div");

        for (var j=0;j<targetList.length-1;j++){
            var targetText=targetList[j+1].firstElementChild.nextElementSibling.innerText;
            if ($(document).scrollTop()>$(targetList[j]).offset().top){
                for (var i=0;i<elelist.length;i++) {
                    var eleText = elelist[i].innerText;
                    if (targetText==eleText) {
                        $(elelist[i]).css("color","#ff6000");
                        $(elelist[i]).css("border-left","2px solid #ff6000");
                        $(elelist[i-1]).css("color","black");
                        $(elelist[i-1]).css("border","none");
                        $(elelist[i-1]).css("border-bottom","1px solid #e4eaee");
                        $(elelist[i+1]).css("color","black");
                        $(elelist[i+1]).css("border","none");
                        $(elelist[i+1]).css("border-bottom","1px solid #e4eaee");
                    }
                }
            }
        }

})




